import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TiktokQuery, TiktokVO, TiktokInfo } from '@/api/operates/tiktok/types';

/**
 * 抖音商品列表
 * @param query 
 * @returns 
 */
export const listTiktok = (query: TiktokQuery): AxiosPromise<TableInfoVO<TiktokVO>> => {
  return request({
    url: '/tiktok/goods/list',
    method: 'get',
    params: query
  });
};

/**
 * 抖音商品详情
 * @param id 
 * @returns 
 */
export const getTiktok = (id: string | number): AxiosPromise<TiktokInfo> => {
  return request({
    url: `/tiktok/goods/${id}`,
    method: 'get'
  });
};

/**
 * 抖音商品上架下架
 * @param id 
 * @returns 
 */
export const enableTiktok = (id: string | number) => {
  return request({
    url: `/tiktok/goods/enable/${id}`,
    method: 'put'
  });
};

/**
 * 绑定或解绑素材id
 * @param id 
 * @returns 
 */
export const materialTiktok = ( query: any ) => {
  return request({
    url: `/tiktok/goods/material/${query.id}`,
    method: 'put',
    params: query
  });
};

/**
 * 抖音商品删除
 * @param id 
 * @returns 
 */
export const delTiktok = (id: string | number) => {
  return request({
    url: `tiktok/goods/${id}`,
    method: 'delete'
  });
};